package com.cencat.order.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单详情VO
 * @author cencat
 * @description 固定商家场景多租户SaaS企业综合管理系统订单详情VO
 * @since 2024-01-01
 */
@Data
@Accessors(chain = true)
@Schema(name = "OrderDetailVO", description = "订单详情VO")
public class OrderDetailVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "订单ID")
    private Long id;

    @Schema(description = "租户ID")
    private Long tenantId;

    @Schema(description = "订单编号")
    private String orderNo;

    @Schema(description = "商家ID")
    private Long merchantId;

    @Schema(description = "商家名称")
    private String merchantName;

    @Schema(description = "用户ID")
    private Long userId;

    @Schema(description = "用户姓名")
    private String userName;

    @Schema(description = "用户手机号")
    private String userPhone;

    @Schema(description = "用户邮箱")
    private String userEmail;

    @Schema(description = "收货人姓名")
    private String receiverName;

    @Schema(description = "收货人手机号")
    private String receiverPhone;

    @Schema(description = "收货人邮箱")
    private String receiverEmail;

    @Schema(description = "收货地址省份")
    private String receiverProvince;

    @Schema(description = "收货地址城市")
    private String receiverCity;

    @Schema(description = "收货地址区县")
    private String receiverDistrict;

    @Schema(description = "收货详细地址")
    private String receiverAddress;

    @Schema(description = "收货地址邮编")
    private String receiverPostcode;

    @Schema(description = "订单状态：PENDING_PAYMENT-待支付，PAID-已支付，SHIPPED-已发货，DELIVERED-已送达，COMPLETED-已完成，CANCELLED-已取消，REFUNDING-退款中，REFUNDED-已退款")
    private String status;

    @Schema(description = "订单状态名称")
    private String statusName;

    @Schema(description = "支付状态：UNPAID-未支付，PAID-已支付，REFUNDED-已退款")
    private String paymentStatus;

    @Schema(description = "支付状态名称")
    private String paymentStatusName;

    @Schema(description = "配送状态：PENDING-待发货，SHIPPED-已发货，DELIVERED-已送达")
    private String shippingStatus;

    @Schema(description = "配送状态名称")
    private String shippingStatusName;

    @Schema(description = "退款状态：NO_REFUND-未退款，PARTIAL_REFUND-部分退款，FULL_REFUND-全额退款")
    private String refundStatus;

    @Schema(description = "退款状态名称")
    private String refundStatusName;

    @Schema(description = "订单类型：NORMAL-普通订单，PRESALE-预售订单，GROUP_BUY-团购订单")
    private String orderType;

    @Schema(description = "订单类型名称")
    private String orderTypeName;

    @Schema(description = "订单来源：WEB-网页，APP-手机应用，MINI_PROGRAM-小程序，H5-手机网页")
    private String orderSource;

    @Schema(description = "订单来源名称")
    private String orderSourceName;

    @Schema(description = "商品总金额")
    private BigDecimal itemsAmount;

    @Schema(description = "配送费用")
    private BigDecimal shippingFee;

    @Schema(description = "优惠金额")
    private BigDecimal discountAmount;

    @Schema(description = "订单总金额")
    private BigDecimal totalAmount;

    @Schema(description = "实付金额")
    private BigDecimal paidAmount;

    @Schema(description = "退款金额")
    private BigDecimal refundAmount;

    @Schema(description = "支付方式：ALIPAY-支付宝，WECHAT-微信支付，BANK_CARD-银行卡，CASH-现金")
    private String paymentMethod;

    @Schema(description = "支付方式名称")
    private String paymentMethodName;

    @Schema(description = "支付流水号")
    private String paymentNo;

    @Schema(description = "支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime paidTime;

    @Schema(description = "配送方式：EXPRESS-快递配送，SELF_PICKUP-自提")
    private String shippingMethod;

    @Schema(description = "配送方式名称")
    private String shippingMethodName;

    @Schema(description = "物流公司")
    private String shippingCompany;

    @Schema(description = "物流单号")
    private String shippingNo;

    @Schema(description = "发货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shippedTime;

    @Schema(description = "送达时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deliveredTime;

    @Schema(description = "完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime completedTime;

    @Schema(description = "取消时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime cancelledTime;

    @Schema(description = "取消原因")
    private String cancelReason;

    @Schema(description = "退款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refundTime;

    @Schema(description = "退款原因")
    private String refundReason;

    @Schema(description = "优惠券ID")
    private Long couponId;

    @Schema(description = "优惠券编码")
    private String couponCode;

    @Schema(description = "是否需要发票：0-不需要，1-需要")
    private Integer needInvoice;

    @Schema(description = "发票类型：PERSONAL-个人，COMPANY-企业")
    private String invoiceType;

    @Schema(description = "发票类型名称")
    private String invoiceTypeName;

    @Schema(description = "发票抬头")
    private String invoiceTitle;

    @Schema(description = "发票税号")
    private String invoiceTaxNo;

    @Schema(description = "发票内容")
    private String invoiceContent;

    @Schema(description = "订单备注")
    private String remark;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "创建人ID")
    private Long createBy;

    @Schema(description = "更新人ID")
    private Long updateBy;

    @Schema(description = "版本号")
    private Integer version;

    @Schema(description = "订单明细列表")
    private List<OrderItemDetailVO> orderItems;

    /**
     * 订单明细详情VO
     */
    @Data
    @Accessors(chain = true)
    @Schema(name = "OrderItemDetailVO", description = "订单明细详情VO")
    public static class OrderItemDetailVO implements Serializable {

        private static final long serialVersionUID = 1L;

        @Schema(description = "订单明细ID")
        private Long id;

        @Schema(description = "订单ID")
        private Long orderId;

        @Schema(description = "订单编号")
        private String orderNo;

        @Schema(description = "商家ID")
        private Long merchantId;

        @Schema(description = "产品ID")
        private Long productId;

        @Schema(description = "产品编码")
        private String productCode;

        @Schema(description = "产品名称")
        private String productName;

        @Schema(description = "产品规格")
        private String productSpec;

        @Schema(description = "产品图片URL")
        private String productImage;

        @Schema(description = "产品单价")
        private BigDecimal unitPrice;

        @Schema(description = "购买数量")
        private Integer quantity;

        @Schema(description = "小计金额")
        private BigDecimal subtotalAmount;

        @Schema(description = "优惠金额")
        private BigDecimal discountAmount;

        @Schema(description = "实际金额")
        private BigDecimal actualAmount;

        @Schema(description = "产品分类ID")
        private Long categoryId;

        @Schema(description = "产品分类名称")
        private String categoryName;

        @Schema(description = "产品品牌ID")
        private Long brandId;

        @Schema(description = "产品品牌名称")
        private String brandName;

        @Schema(description = "产品重量(克)")
        private BigDecimal weight;

        @Schema(description = "产品体积(立方厘米)")
        private BigDecimal volume;

        @Schema(description = "退款状态：NO_REFUND-未退款，PARTIAL_REFUND-部分退款，FULL_REFUND-全额退款")
        private String refundStatus;

        @Schema(description = "退款状态名称")
        private String refundStatusName;

        @Schema(description = "退款金额")
        private BigDecimal refundAmount;

        @Schema(description = "退款时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime refundTime;

        @Schema(description = "退款原因")
        private String refundReason;

        @Schema(description = "明细备注")
        private String remark;

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;

        @Schema(description = "更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updateTime;
    }
}